package org.jeecg.common.job.data.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.jeecg.common.datasource.annotation.DBColumn;
import org.jeecg.common.datasource.annotation.DBTable;
import org.jeecg.common.job.enums.JobConstants;

import java.io.Serializable;
import java.util.Date;

/**
 * @author zhaoguoqiang
 * @version 2020年01月19 15:49
 */
@Setter
@Getter
@DBTable(name = "sys_job_config")
@ApiModel(value = "Job", description = "任务信息")
public class JobInfoVo implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键")
    @DBColumn(isPrimaryKey = true)
    private String id;

    @ApiModelProperty(value = "任务名称", required = true)
    @DBColumn(name = "name")
    private String name;

    @ApiModelProperty(value = "名称", required = true)
    @DBColumn(name = "bean_name")
    private String beanName;

    @ApiModelProperty(value = "方法", required = true)
    @DBColumn(name = "bean_method")
    private String beanMethod;

    @ApiModelProperty(value = "时间计划", required = true)
    @DBColumn(name = "cycle_time")
    private String cycleTime;

    @ApiModelProperty(value = "执行模式", required = true)
    @DBColumn(name = "execute_mode")
    private Integer executeMode;

    @ApiModelProperty(value = "是否删除， 0.未删除 1.已删除", hidden = true)
    @DBColumn(name = "del_sign")
    private Integer delSign;

    @ApiModelProperty(value = "是否删除， 0.开启 1.暂停", hidden = true)
    @DBColumn(name = "status")
    private Integer status;

    @ApiModelProperty(value = "创建时间", hidden = true)
    @DBColumn(name = "create_time")
    private Date createTime;

    @ApiModelProperty(value = "更新时间", hidden = true)
    @DBColumn(name = "update_time")
    private Date updateTime;

    @DBColumn()
    @ApiModelProperty(value = "状态名称", hidden = true)
    private String statusName;

    @ApiModelProperty(value = "最后一次执行时间", hidden = true)
    @DBColumn(name = "last_time")
    private Date lastTime;

    public String getStatusName() {
        JobConstants.JobStatus status = JobConstants.JobStatus.get(this.getStatus());
        if (null != status) {
            return status.getName();
        }
        return "";
    }

    @ApiModelProperty(value = "节点名称", required = true)
    @DBColumn(name = "node_name")
    private String nodeName;
}
